<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
  <title>员工编辑</title>
  <style>
    body { font-family: Arial, sans-serif; background-color: #f5f5f5; }
    .container { width: 500px; margin: 30px auto; padding: 20px; background: white; border-radius: 5px; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
    h1 { text-align: center; color: #333; }
    .form-group { margin-bottom: 20px; }
    label { display: block; margin-bottom: 5px; font-weight: bold; color: #555; }
    input[type="text"], input[type="number"], input[type="date"], select {
      width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box;
    }
    .btn-container { display: flex; justify-content: space-between; margin-top: 20px; }
    .btn { padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; }
    .btn-primary { background-color: #4CAF50; color: white; }
    .btn-secondary { background-color: #f44336; color: white; }
  </style>
</head>
<body>
<div class="container">
  <h1>员工编辑</h1>

  <form action="updateEmployee" method="post">
    <input type="hidden" name="id" value="${employee.id}">

    <div class="form-group">
      <label for="name">姓名：</label>
      <input type="text" id="name" name="name" value="${employee.name}" required>
    </div>

    <div class="form-group">
      <label for="gender">性别:</label>
      <select id="gender" name="gender" required>
        <option value="Male" ${employee.gender == 'male' ? 'selected' : ''}>男</option>
        <option value="Female" ${employee.gender == 'female' ? 'selected' : ''}>女</option>
        <option value="Other" ${employee.gender == 'other' ? 'selected' : ''}>其他</option>
      </select>
    </div>

    <div class="form-group">
      <label for="age">年龄:</label>
      <input type="number" id="age" name="age" min="18" max="65" value="${employee.age}" required>
    </div>

    <div class="form-group">
      <label for="deptId">部门:</label>
      <select id="deptId" name="deptId" required>
        <c:forEach items="${departments}" var="dept">
          <option value="${dept.deptId}" ${employee.deptId == dept.deptId ? 'selected' : ''}>
              ${dept.deptName}
          </option>
        </c:forEach>
      </select>
    </div>

    <div class="form-group">
      <label for="position">职务:</label>
      <input type="text" id="position" name="position" value="${employee.position}" required>
    </div>



    <div class="btn-container">
      <button type="button" class="btn btn-secondary" onclick="window.location.href='employees'">返回</button>
      <button type="submit" class="btn btn-primary">编辑员工</button>
    </div>
  </form>
</div>
</body>
</html>
